import lib
import os
import time
import datetime
import sys
import logging
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext import db
from google.appengine.api import datastore_errors
from model.models import *
from lib.workflow import *
from google.appengine.api import mail

class WFMailer():
  
  def mailView(self, request,step, recipients):
    logging.debug("Sending mail for revision")
    request_info = request.toString()
    link = "http://apppsteps.appspot.com/steps/"+str(step.key().id())
    
    recipient = recipients[0]
    
    message = mail.EmailMessage(sender="PSteps Deamon <leonardo@luarte.net>",
                            subject="Please review request " + request.name)

    message.to = recipient.email
    message.body = "You need to check this step.\n"
    message.body = message.body + request_info
    message.body = message.body + "\nCheck it online in " + link

    message.send()
    
    
    
  
  def execute(self):
    logging.debug("Executing processor")
    self.internal_execute()
    pass
  
  